<template>
  <div class="card content-box">
    <el-form :model="formData" style="width: 260" label-width="80px">
      <el-form-item class="item" :label="t('accessControl.personalInformation.loginAccount')" prop="loginName">
        <el-input v-model="formData.loginName" />
      </el-form-item>
      <el-form-item class="item" :label="t('accessControl.personalInformation.name')" prop="fullName">
        <el-input v-model="formData.fullName" />
      </el-form-item>
      <el-form-item class="item" :label="t('accessControl.personalInformation.organization')" prop="officeFax">
        <el-input v-model="formData.orgName" />
      </el-form-item>
      <el-form-item class="item" :label="t('accessControl.personalInformation.gender')">
        <el-input v-model="formData.sex" />
      </el-form-item>
      <el-form-item class="item" :label="t('accessControl.personalInformation.email')" prop="email">
        <el-input v-model="formData.email" />
      </el-form-item>
      <el-form-item class="item" :label="t('accessControl.personalInformation.mobile')">
        <el-input v-model="formData.phone" />
      </el-form-item>
      <el-form-item class="item" :label="t('accessControl.personalInformation.officePhone')">
        <el-input v-model="formData.moblie" />
      </el-form-item>
    </el-form>
  </div>
</template>

<script setup lang="ts" name="basicForm">
import { ElMessage, FormInstance, FormRules } from "element-plus";
import { ref, reactive, onMounted, onBeforeUnmount } from "vue";
import { findUserDetail, getCurrentLoginUser } from "@/api/modules/accessController";
import { useI18n } from "vue-i18n";

const { t } = useI18n();

const ruleFormRef = ref<FormInstance>();

const formData = reactive({
  loginName: "",
  fullName: "",
  orgName: "",
  sex: "",
  email: "",
  phone: "",
  moblie: ""
});

onMounted(() => {
  getCurrentLoginUser().then(res => {
    let newParams = JSON.parse(JSON.stringify(res));
    formData.loginName = newParams.loginName;
    formData.fullName = newParams.fullName;
    formData.orgName = newParams.orgName;
    formData.sex =
      newParams.sex == true ? t("accessControl.personalInformation.male") : t("accessControl.personalInformation.female");
    formData.email = newParams.email;
    formData.phone = newParams.phone;
    formData.moblie = newParams.moblie;
  });
  // //加载公司信息
  // findUserDetail({ userId: 30 }, "userDto").then(res => {
  //   let newParams = JSON.parse(JSON.stringify(res));
  //   formData.loginName = newParams.loginName;
  //   formData.fullName = newParams.fullName;
  //   formData.orgName = newParams.orgName;
  //   formData.sex = newParams.sex == true ? "男" : "女";
  //   formData.email = newParams.email;
  //   formData.phone = newParams.phone;
  //   formData.moblie = newParams.moblie;
  // });
});
</script>

<style scoped lang="scss">
@import "./index";
.item {
  width: 500px;
}
</style>
